import {HttpGet, HttpPost} from "@/api/index.js";

/**
 * 添加菜单
 * @param menu
 * @constructor
 */
export const add = (menu) => {
    return HttpPost("/admin/system/menu/add", menu)
}

/**
 * 删除菜单
 * @param menuId
 * @constructor
 */
export const deleteById = (menuId) => {
    return HttpPost("/admin/system/menu/deleteById/" + menuId)
}

/**
 * 更新菜单
 * @param menu
 * @constructor
 */
export const edit = (menu) => {
    return HttpPost("/admin/system/menu/update", menu)
}

/**
 * 根据pid获取子节点列表
 * @param pid
 * @constructor
 */
export const listById = (pid) => {
    return HttpPost("/admin/system/menu/listByPid", pid)
}

/**
 * 获取全部的菜单树
 * @constructor
 */
export const allTree = () => {
    return HttpGet("/admin/system/menu/allTree")
}

/**
 * 通过角色ID获取分配的权限集合
 * @param roleId
 */
export const listByRoleId = (roleId) => {
    return HttpGet("/admin/system/menu/listByRoleId", {roleId})
}
